//
//  SignalViewController.m
//  Select
//
//  Created by dihuijun on 17/3/17.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "SignalViewController.h"
#import "signalView.h"
@interface SignalViewController ()
/**   datasource   */
@property (nonatomic, strong) NSMutableArray *datasource;
/**   signalView   */
@property (nonatomic, strong) signalView *sigView;
@end

@implementation SignalViewController
/**   datasource   */
- (NSMutableArray *)datasource{
    if(!_datasource){
        _datasource = [NSMutableArray arrayWithObjects:@"张三",@"张飞",@"赵云",@"礼拜",@"王五", nil];
    }
    return _datasource;
}
/**   signalView   */
- (signalView *)sigView{
    if(!_sigView){
        _sigView = [signalView initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, self.view.frame.size.height)];
        
        ///服务器数据传过去
        _sigView.datasource = self.datasource;
        //得到选中的
        _sigView.block = ^(NSString *content,NSIndexPath *indexPath){
            NSLog(@"\n选中的content: %@ ,\n第 %zd 行",content,indexPath.row);
        };
        
    }
    return _sigView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"单选";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Add" style:UIBarButtonItemStyleDone target:self action:@selector(addClick)];
    
    [self.view addSubview:self.sigView];
    
}


/**  添加数据*/
- (void)addClick{
    
    NSUInteger count = self.datasource.count;
    for (int i=0; i<=5; i++) {
        [self.datasource addObject:[NSString stringWithFormat:@"%lu",count+i]];
    }
    
    self.sigView.datasource = self.datasource;
    
    [self.sigView reloadData];
    
    
    
    
    
    
}
@end
